/*  sock_lib.h
 *  for socket operations
 *  by vess
 */

#ifndef _SOCK_LIB_H
#define _SOCK_LIB_H

/* wsaStartup
 * return value: 0 for ok, -1 for not ok.
 */
int Startup();

/* wsaCleanup
 */
void Cleanup();

/*  connect to a server
 *  [in]   hostname(or ip_addr), port number
 *  [ret]  the socket, -1 for error.
 */
SOCKET Connect(char *hostname, char *port);

/*  moniter a port
 *  [in]   port_number
 *  [ret]  the socket, -1 for error.
 */
SOCKET Monitor(char *port);

/*  accpet a client
 *  [in]   serversocket
 *  [out]  clientname
 *  [ret]  accepted socket, -1 for error
 */
SOCKET Accept(SOCKET serversocket, char *clientname);

/*  send a string to the dest_socket
 *  [in]   destsocket
 *  [in]   buf
 *  [in]   length
 *  [ret]  sent length, -1 for error
 */
int Send(SOCKET destsocket, const char *buf, int length);

/*  receive a string from the client_socket
 *  [in]   clientsocket
 *  [in]   buf
 *  [in]   length
 *  [ret]  received length, -1 for error
 */
int Recv(SOCKET clientsocket, char *buf, int length);

#endif 